from fastapi import FastAPI
from app.lifespan import lifespan
from app.router import router


# 创建FastAPI应用实例，使用lifespan管理资源
app = FastAPI(
    title="语音识别服务",
    description="基于Paraformer模型的中文语音识别服务",
    version="1.0.0",
    lifespan=lifespan
)


# 注册路由
app.include_router(router, prefix="/v1/audio")


@app.get("/")
async def root():
    """
    根路径，返回API信息
    """
    return {
        "message": "欢迎使用语音识别服务",
        "version": "1.0.0",
        "docs": "/docs"
    }


@app.get("/health")
async def health_check():
    """
    健康检查端点
    """
    return {"status": "healthy"}


if __name__ == "__main__":
    import uvicorn
    uvicorn.run(app, host="0.0.0.0", port=8000)